<?php
header("Content-type: text/plain; charset=utf-8", true);

if ($_SERVER["REQUEST_METHOD"] == "GET" && isset($_GET["service-source"])) {
    echo file_get_contents(__FILE__);
    return;
}

require_once("lib/jsonss.php");

class HelloService extends JSONSSService {
    public function SayHello($p) {
        return "Hello, world!";
    }

    public function __construct() {
        $this->add_method("SayHello", "say-hello");
    }
}

$server = new JSONSSServer();
$server->add_service(new HelloService(), "HelloService", "hello-service");
$server->process_request();
